<?php
/**
 * @version        $Id: buy.php 1 8:38 2010年7月9日Z tianya $
 * @package        DedeCMS.Member
 * @copyright      Copyright (c) 2007 - 2010, DesDev, Inc.
 * @license        http://help.dedecms.com/usersguide/license.html
 * @link           http://www.dedecms.com
 */
require_once(dirname(__FILE__).'/config.php');
CheckRank(0,0);
$menutype = 'mydede';
$menutype_son = 'certification';

if($dopost == 'edit'){
	
	if($type == 'sfrz')
	{
		$maxlength = 1024 * 1024;
		$userdir = $cfg_user_dir.'/'.$cfg_ml->M_ID;
		if(!preg_match("#^".$userdir."#", $oldusfzzp))
		{
			$oldusfzzp = '';
		}
		if(is_uploaded_file($usfzzp))
		{
			if(@filesize($_FILES['usfzzp']['tmp_name']) > $maxlength)
			{
				ShowMsg("你上传的头像文件超过了系统限制大小：1024 K！", '-1');
				exit();
			}
			//删除旧图片（防止文件扩展名不同，如：原来的是gif，后来的是jpg）
			if(preg_match("#\.(jpg|gif|png)$#i", $oldusfzzp) && file_exists($cfg_basedir.$oldusfzzp))
			{
				@unlink($cfg_basedir.$oldusfzzp);
			}
			//上传新工图片
			$usfzzp = MemberUploads('usfzzp', $oldusfzzp, $cfg_ml->M_ID, 'image', 'usfzzp', 800, 501);
		}
		else
		{
			$usfzzp = $oldusfzzp;
		}
		
		$inquery = "UPDATE `#@__member_certification` SET zuname='$zuname', utel='$utel', uqq='$uqq', usfz='$usfz', usfzzp='$usfzzp',  uzfb='$uzfb', utime='".time()."', sta='1' WHERE mid='".$cfg_ml->M_ID."'";
		//记录数据
		if( !$dsql->ExecuteNoneQuery($inquery) )
		{
			ShowMsg('记录数据失败, 请返回', '-1');
			exit(0);
		}
		else
		{
			//更新认证状态
			$dsql->ExecuteNoneQuery("UPDATE `#@__member` SET certification = 1 WHERE mid='".$cfg_ml->M_ID."'");
			$dsql->ExecuteNoneQuery("UPDATE `#@__member_person` SET qq='$uqq', mobile='$utel', uptime='".time()."', zuname='$zuname', usfz='$usfz', usfzzp='$usfzzp', uzfb='$uzfb' WHERE mid='".$cfg_ml->M_ID."' ");
			 
			 
			//查询管理员的uid
			$row = $dsql->GetOne("SELECT userid FROM `#@__member` WHERE mid='1'");
			$uid = $row['userid'];

			//给管理员发送消息
			$dsql->ExecuteNoneQuery("INSERT INTO `#@__member_pms`(floginid,fromid,toid,tologinid,folder,subject,sendtime,writetime,hasview,isadmin,message,contesfs,lxlx,type,rzid) VALUES ('".$cfg_ml->M_LoginID."','".$cfg_ml->M_ID."','1','$uid','inbox','用户[".$cfg_ml->M_LoginID."]申请了实名认证','".time()."','".time()."','0','0','用户[".$cfg_ml->M_LoginID."]修改了实名认证资料，请审核资料是否合格。','','','4','".$cfg_ml->M_ID."'); ");
			
			ShowMsg('提交成功，等待管理员审核','certification.php');
			exit();
		}
	}
}else{
	ShowMsg('本页面禁止返回','/');
	exit();
}
?>